function cache(target, propertyKey,descriptor){
    const originalMethod = descriptor.value
    let cacheMap = new Map()
    descriptor.value = function (...args){
        const key = JSON.stringify(args)
        if (cacheMap.has(key)) {
            return cacheMap.get(key)
        }
        let result = originalMethod.apply(this, args)
        console.log('www', args, cacheMap)
        cacheMap.set(key, result,)
        return result
    }
    return descriptor
}
class MathOperations{
    @cache
    factorial(n){
        if (n<=1) return 1
        return n *this.factorial(n-1)
    }
}
const mathOperations = new MathOperations()
console.log(mathOperations.factorial(5))
console.log(mathOperations.factorial(5))